﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Collections;

namespace Trig_AMJ_IT_Customforms.Layouts.Trig_AMJ_IT_Customforms
{
    public partial class IT_Helpdesk_Form : LayoutsPageBase
    {

        SPHelper obj = new SPHelper();

        #region "Properties"

        string CurrentUser = SPContext.Current.Web.CurrentUser.LoginName;

        public static string SiteURL;
        public static string TicketNo;
        public static string MainLstName;
        public static string TaskLstName;
        public static string AttLibName;
        public static string CmntsLstName;
        public static string WorkflowConfigList;
        public static string lstGuid { get; set; }
        public string camlQry { get; set; }
        public static string Mode { get; set; }

        string ErrorMsgs;

        public static string DocumentTypesList { get; set; }
        string WFCurrentOrder = string.Empty;
        string WFTaskType = string.Empty;

        Demand_Voucher_FormClass demandVoucherclass = new Demand_Voucher_FormClass(); // Helper class for this solution
        Trig_WF trigWFClass = new Trig_WF();

        string[] buttonVisibilty = new string[5];

        Label EmpName; Label EmpID; Label Division; Label Department; Label Designation; Label MobNo;

        #endregion

        /// <summary>
        /// Constructor to store List names
        /// </summary>

        public IT_Helpdesk_Form()
        {
            SiteURL = SPContext.Current.Site.Url;
            SiteURL = SiteURL + "/sites/forms/";
            MainLstName = "IT Helpdesk Forms";
            TaskLstName = "IT Helpdesk Tasks";
            CmntsLstName = "IT Helpdesk Comments";
            AttLibName = "Attachments";
            WorkflowConfigList = "Workflow Configuration List";
            DocumentTypesList = "DocumentTypes";
        }

        #region "User control manipulation"
        /// <summary>
        /// Get user control controls using find control method 
        /// </summary>
        private void GetUserControls()
        {
            EmpName = userInfo.FindControl("lblEmpName") as Label;
            EmpID = userInfo.FindControl("lblEmpID") as Label;
            Division = userInfo.FindControl("lblDivision") as Label;
            Department = userInfo.FindControl("lblDepartment") as Label;
            Designation = userInfo.FindControl("lblDesignation") as Label;
            MobNo = userInfo.FindControl("lblMobNo") as Label;
        }

        #endregion

        #region "Page Load"

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Mode = Request.QueryString["Mode"];
                dtpDate.SelectedDate = DateTime.Today;
                
                GetUserControls(); // Get Loggedin user details from user profile and assign to user control. 

                if (!IsPostBack)
                {
                    ddlReqCategory.Items.Clear();
                    obj.GetRequestCategories("IT Request Categories", ddlReqCategory, SiteURL);

                    ImgUser.ImageUrl = demandVoucherclass.GetUserProfilePictureURL(CurrentUser);
                    LblCommentsUserName.Text = CurrentUser;
                    if (Mode == "Edit" || Mode=="View")
                    {
                        FormApprovalLoad(); if (Mode == "View") InvisibleButtons();
                    }
                    else if (Mode == "New")
                    {
                        FirstLoadofForm();
                    }
                    else
                    {
                        pnlFullForm.Visible = false;
                        pnlAccessDenied.Visible = true;
                        lblAccessDeniedMsg.Visible = true;
                        lblAccessDeniedMsg.Text = "Unable to open the form. Value is missing. Contact administrator";
                    }
                }

            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms :: IT Helpdesk Form" + " :: " + "Parent" + " :: " + "Page_Load";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }

            if (Mode == "New" && rdBtn.SelectedIndex == 1)
            { GetReqEmpInfo(); }

            rdBtn.SelectedIndexChanged += new EventHandler(rdBtn_SelectedIndexChanged);
            btnSubmit.Click += new EventHandler(btnSubmit_Click);
            btnReject.Click += new EventHandler(btnReject_Click);
            btnApprove.Click += new EventHandler(btnApprove_Click);

            rtbForward.CheckedChanged += new EventHandler(rtbForward_CheckedChanged);
            rtbSendBack.CheckedChanged += new EventHandler(rtbSendBack_CheckedChanged);
            rtbForwardOthers.CheckedChanged += new EventHandler(rtbForwardOthers_CheckedChanged);

        }

        private void InvisibleButtons()
        {
            btnCntrls.Visible = false;
            pnlView.Visible = true;
            btnSubmit.Visible = false;
            btnApprove.Visible = false;
            btnReject.Visible = false;
            pnlForward.Visible = false;
            pnlCommentArea.Visible = false;
            upAtt.Visible = false;
            btnCancel.Value = "Close";
        }


        /// <summary>
        /// Check whether the form is in Document Types List also get Document prefix and starting number
        /// </summary>
        public void FirstLoadofForm()
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
              {
                  string[] getDocRefNumber = demandVoucherclass.getRefNum(SiteURL, DocumentTypesList, MainLstName);
                  if (string.IsNullOrEmpty(getDocRefNumber[0]) && string.IsNullOrEmpty(getDocRefNumber[1]))
                  {
                      pnlFullForm.Visible = false;
                      pnlAccessDenied.Visible = true;
                      lblAccessDeniedMsg.Visible = true;
                      lblAccessDeniedMsg.Text = "Access Denied, DocPrefix or Starting Number column value in Document Types Master list is missing. Contact administrator.";
                  }

              });
            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms :: IT Helpdesk Form" + " :: " + "Parent" + " :: " + "FirstLoadofForm";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }
        }


        /// <summary>
        /// Depends upon the Approvers option in Work flow config list, the button will be shown in form.
        /// Approvers can send back to previous user.forward to other user and forward to next workflow user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        #region "Appovers option Button"

        void rtbForward_CheckedChanged(object sender, EventArgs e)
        {
            lblError.Text = "";
            lblWFStaticUser.Text = "If you press Submit/Approve the workflow will go to next step";
        }

        void rtbForwardOthers_CheckedChanged(object sender, EventArgs e)
        {
            lblWFStaticUser.Text = "";
            lblError.Text = "";
        }

        void rtbSendBack_CheckedChanged(object sender, EventArgs e)
        {
            lblError.Text = "";
            SPFieldUserValue ofldUser = demandVoucherclass.getSendBackUserfNametoAssignLabelText(SiteURL, TaskLstName, Convert.ToInt16(Request.Params["TaskItemID"]), lblTxkNo.Text, rtbSendBack, rtbForward, lblError);
            if (ofldUser != null)
            {
                lblWFStaticUser.Text = "Send back to " + ofldUser.User.Name;
                lblSendBacktoUser.Text = ofldUser.User.Name;
            }
        }

        #endregion

        void btnApprove_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string formID = null;
                string refNo = Request.QueryString["RefID"];
                string taskItemID = Request.QueryString["TaskItemID"];
                string Approver = SPContext.Current.Web.CurrentUser.LoginName;
                if (GetSendbackStatus())
                {
                    if (CheckServersideValidation())
                    {
                        SPLongOperation lop = new SPLongOperation(this.Page);
                        lop.LeadingHTML = "<DIV><H4>IT Helpdesk form approval is in progress</H4></DIV>";
                        lop.TrailingHTML = "<DIV><H5>Please wait...</H5></DIV>";
                        lop.Begin();
                        obj.ApprovetheForm(SiteURL, MainLstName, TaskLstName, WorkflowConfigList, CmntsLstName, AttLibName, formID, refNo, taskItemID, WFTaskType, Approver,
                            TxtComments.Text, upfile, rtbForwardOthers, rtbSendBack, pplcnt,true);
                        lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");
                    }
                }
                else
                {
                   
                    //lblError.Text = "Can't be send back. User is not available";
                    SPLongOperation lop = new SPLongOperation(this.Page);
                    lop.LeadingHTML = "<DIV><H4>IT Helpdesk form approval is in progress</H4></DIV>";
                    lop.TrailingHTML = "<DIV><H5>Please wait...</H5></DIV>";
                    lop.Begin();
                    obj.ApprovetheForm(SiteURL, MainLstName, TaskLstName, WorkflowConfigList, CmntsLstName, AttLibName, formID, refNo, taskItemID, WFTaskType, Approver,
                        TxtComments.Text, upfile, rtbForwardOthers, rtbSendBack, pplcnt, true);
                    lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");
                }
            }
        }

        void btnReject_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                SPLongOperation lop = new SPLongOperation(this.Page);
                lop.LeadingHTML = "<DIV><H4>IT Helpdesk form rejection in progress</H4></DIV>";
                lop.TrailingHTML = "<DIV><H5>Please wait...</H5></DIV>";
                lop.Begin();

                //string formID = null;// Request.QueryString["FormID"];
                string refNo = Request.QueryString["RefID"];
                string TaskItemID = Request.QueryString["TaskItemID"];

                try
                {
                    Label formID = userInfo.FindControl("lblFormID") as Label;

                    SPFieldUserValue userValue = obj.GetSubmittedUser(SiteURL, formID.Text.ToString().Trim(), refNo);

                    if (userValue.LookupValue.ToLower() == SPContext.Current.Web.CurrentUser.LoginName.ToLower())
                    {
                        obj.RejectForUser(SiteURL, MainLstName, TaskLstName, CmntsLstName, 2, AttLibName, upfile, WorkflowConfigList, refNo, formID.Text.ToString().Trim(), TxtComments.Text, null, TaskItemID);
                    }
                    else
                    {
                        trigWFClass.RejectTask(SiteURL, Request.QueryString["TaskItemID"], TaskLstName, MainLstName, Request.QueryString["RefID"]);
                    }
                }
                catch (Exception ex)
                {
                    ErrorMsgs = "Trig_AMJ_IT_Forms :: IT Helpdesk Form" + " :: " + "Parent" + " :: " + "Reject";
                    obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
                }
               
                lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");

            }
        }

        #endregion

        /// <summary>
        /// check the user availability
        /// </summary>
        /// <returns></returns>
        
        public bool GetSendbackStatus()
        {
            bool status = true;
            if (rtbSendBack.Checked)
            {
                SPFieldUserValue ofldUser = demandVoucherclass.getSendBackUserfNametoAssignLabelText(SiteURL , TaskLstName, Convert.ToInt16(Request.Params["TaskItemID"]), lblTxkNo.Text, rtbSendBack, rtbForward, lblError);
                if (ofldUser == null)
                {
                    status = false;
                }
            }
            return status;
        }
        
        /// <summary>
        /// Form Approval 
        /// </summary>

        public void FormApprovalLoad()
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    string TaskItemID = Convert.ToString(Request.QueryString["TaskItemID"]);
                    if (!string.IsNullOrEmpty(TaskItemID))
                    {
                        using (SPSite FrmSite = new SPSite(SiteURL))
                        {
                            using (SPWeb frmweb = FrmSite.OpenWeb())
                            {
                                SPQuery updatecamQ = new SPQuery();
                                updatecamQ.Query = "<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + TaskItemID + "</Value></Eq></Where>";
                                if (frmweb.Lists.TryGetList(TaskLstName) != null)
                                {
                                    SPListItemCollection oitemcoll = frmweb.Lists.TryGetList(TaskLstName).GetItems(updatecamQ);
                                    if (oitemcoll.Count > 0)
                                    {
                                        SPListItem oitm = oitemcoll[0];
                                        WFCurrentOrder = Convert.ToString(oitm["WFCurrentOrder"]);
                                        WFTaskType = Convert.ToString(oitm["WFTaskType"]);
                                        if (WFTaskType == "Dynamic")
                                        {
                                            pnlForward.Visible = true;
                                        }
                                        RadioButtionListvisibility(frmweb, WFTaskType, false, "", Convert.ToInt32(WFCurrentOrder));
                                    }
                                }
                            }
                        }
                    }
                    ReLoadDetails();
                    //ControlsReadOnly();
                });
            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms" + " :: " + "Parent" + " :: " + "FormApprovalLoad";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }
        }

        
        /// <summary>
        /// Hide or Show the Requested Employee Information depends upon the On Behalf of section
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rdBtn_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rdBtn.SelectedIndex == 0)
                pnlReqEmpInf.Visible = false;
            else
                pnlReqEmpInf.Visible = true;
        }


        /// <summary>
        /// Submit the form 
        /// Generate IT Helpdesk Ticket No generation
        /// Add values to Helpdesk Forms
        /// Add values to Helpdesk Forms Task List
        /// Add values to Comment List
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        #region "Submit Button"

        private void btnSubmit_Click(object sender, EventArgs e)
        {

            if (Page.IsValid)
            {
                if (Request.QueryString["Mode"] == "Edit")
                {
                    string formID = null;// Request.QueryString["FormID"];
                    string refNo = Request.QueryString["RefID"];
                    string taskItemID = Request.QueryString["TaskItemID"];
                    string Approver = SPContext.Current.Web.CurrentUser.LoginName;

                    if (GetSendbackStatus())
                    {
                        if (CheckServersideValidation())
                        {
                            SPLongOperation lop = new SPLongOperation(this.Page);
                            lop.LeadingHTML = "<DIV><H4>IT Helpdesk form approval is in progress</H4></DIV>";
                            lop.TrailingHTML = "<DIV><H5>Please wait...</H5></DIV>";
                            lop.Begin();
                            obj.ApprovetheForm(SiteURL, MainLstName, TaskLstName, WorkflowConfigList, CmntsLstName, AttLibName, formID, refNo, taskItemID, WFTaskType, Approver,
                                TxtComments.Text, upfile, rtbForwardOthers, rtbSendBack, pplcnt,false);
                            lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");
                        }
                    }
                    else
                    {
                        lblError.Text = "Can't be send back. User is not available";
                    }
                }
                else if (Request.QueryString["Mode"] == "New")
                {
                    SaveFormDetails();
                }
            }

        }

        #endregion

        /// <summary>
        /// Save Form details 
        /// Add Items in Main List
        /// Add Items in Task List
        /// Add Items in Comments List
        /// Add Attachment to Attachment Library
        /// </summary>

        private void SaveFormDetails()
        {
            SPLongOperation lop = new SPLongOperation(this.Page);
            lop.LeadingHTML = "<DIV><H4>IT Helpdesk form submission is in progress...</H4></DIV>";
            lop.TrailingHTML = "<DIV><H5>Please wait...</H5></DIV>";
            
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                obj.AutoNoGeneration(MainLstName,DocumentTypesList, lblTxkNo, SiteURL);
                TicketNo = Convert.ToString(lblTxkNo.Text).Trim();
                if (TicketNo.Contains(DateTime.Now.Year.ToString()))
                {
                    lop.Begin();
                    lstGuid = obj.AddITItems(SiteURL, MainLstName, TaskLstName, CmntsLstName, rdBtn.SelectedIndex, AttLibName, upfile, WorkflowConfigList, pplcnt, lblTxkNo.Text,
                        Convert.ToString(dtpDate.SelectedDate), CurrentUser, EmpID.Text, Division.Text, Designation.Text, "", ddlReqCategory.SelectedItem.Text,
                        ddlReqPriority.SelectedItem.Text, "", pplReqUser.CommaSeparatedAccounts, txtReqUserID.Text, txtReqUserDept.Text, txtReqUserPosCategory.Text,
                        txtReqUserMobNo.Text, txtReqUserDivision.Text, Division.Text, TxtComments.Text);
                    lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");
                }
                else
                {
                    lblError.Text = "Master list details not in Doecument Types"; lblError.ForeColor = System.Drawing.Color.Red;
                }
            });
            //lop.End(SPContext.Current.Site.Url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, "");
        }

        /// <summary>
        /// Check people editor validations
        /// </summary>
        /// <returns></returns>
        
        public bool CheckServersideValidation()
        {
            bool rval = true;
            if (rtbForwardOthers.Checked)
            {
                if (pplcnt.Accounts.Count > 0)
                {
                    rval = true;
                }
                else
                {
                    rval = false;
                    lblError.Text = "Please enter the user name to forward";
                }
            }
            return rval;
        }

        /// <summary>
        /// Function to bind data after the Form gets submitted.
        /// </summary>
        /// <param name="SiteURL"></param>

        #region "Reload Forms"

        public void ReLoadDetails()
        {
            try
            {
                string RefNo = Convert.ToString(Request.Params["RefID"]);

                camlQry = "<Where><Eq><FieldRef Name=\"Reference_x0020_Number\" /><Value Type=\"Text\">" + RefNo + "</Value></Eq></Where>";
                SPListItem lstDatas = obj.GetSPListItem(SiteURL, MainLstName, camlQry);
                if (lstDatas != null)
                {
                    lblTxkNo.Text = Convert.ToString(lstDatas["Reference Number"]);
                    dtpDate.SelectedDate = Convert.ToDateTime(lstDatas["RequestDate"]);
                    ddlReqCategory.SelectedItem.Text = Convert.ToString(lstDatas["RequestCategories"]);
                    ddlReqCategory.SelectedItem.Selected = true;
                    ddlReqPriority.SelectedValue = Convert.ToString(lstDatas["RequestPriority"]);
                    ddlReqCategory.Enabled = false;
                    ddlReqPriority.SelectedItem.Selected = true;
                    ddlReqPriority.Enabled = false;

                    Label lblFormID = userInfo.FindControl("lblFormID") as Label;
                    lblFormID.Text = lstDatas.ParentList.ID.ToString();

                    Label lblreferenceNumber = itComments.FindControl("lblReferenceNumber") as Label;
                    Label lblSiteUrl = itComments.FindControl("lblSiteUrl") as Label;
                    Label lblfrmListName = itComments.FindControl("lblfrmListName") as Label;
                    Label lbldocumentypesList = itComments.FindControl("lbldocumentTypes") as Label;
                    Label lblCommentsList = itComments.FindControl("lblCommentsList") as Label;
                    Label lblTaskList = itComments.FindControl("lblTaskList") as Label;

                    lblTaskList.Text = TaskLstName;
                    lblCommentsList.Text = CmntsLstName ;
                    lblfrmListName.Text = MainLstName;
                    lbldocumentypesList.Text = DocumentTypesList;
                    lblreferenceNumber.Text = lblTxkNo.Text;
                    lblSiteUrl.Text = SiteURL;

                    if (Convert.ToString(lstDatas["OnBehalfof"]) == "Yes")
                    {
                        pnlSec.Visible = true;
                        pnlSec.Enabled = false;
                        rdBtn.SelectedIndex = 1;
                        pnlReqEmpInf.Visible = true;
                        SetValuestoOnBehalfof(lstDatas);
                    }

                    else
                    {
                        pnlSec.Visible = true;
                        pnlSec.Enabled = false;
                        rdBtn.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms" + " :: " + "Parent" + " :: " + "ReLoadDetails";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }
        }

        #region "Set Values to OnBehalfof"

        private void SetValuestoOnBehalfof(SPListItem lstDatas)
        {
            SPFieldUserValue user = new SPFieldUserValue(SPContext.Current.Web, lstDatas["SubmittedFor"].ToString());
            //setPeopleEditors(user, pplReqUser);

            pplReqUser.Visible = false;
            txtReqUser.Visible = true; txtReqUser.ReadOnly = true;
            txtReqUser.Text = user.LookupValue.ToString();
            txtReqUserID.Text = Convert.ToString(lstDatas["EmployeeID"]);
            txtReqUserDivision.Text = Convert.ToString(lstDatas["Division"]);
            txtReqUserDept.Text = Convert.ToString(lstDatas["Department"]);
            txtReqUserPosCategory.Text = Convert.ToString(lstDatas["Designation"]);
            txtReqUserMobNo.Text = Convert.ToString(lstDatas["MobileNo"]);
            txtReqUserMobNo.Enabled = false;
        }

        private void setPeopleEditors(SPFieldUserValue user, PeopleEditor ppls)
        {
            ArrayList _arrayList = new ArrayList();
            if (user != null)
            {
                PickerEntity _pickerEntity = new PickerEntity(); // PickerEntitiy use using Microsoft.SharePoint.WebControls
                _pickerEntity.Key = user.LookupValue;
                _pickerEntity.IsResolved = true;
                _arrayList.Add(_pickerEntity);
                ppls.UpdateEntities(_arrayList);
                ppls.Enabled = false;
            }

        }

        #endregion

        #endregion

        /// <summary>
        /// Get requested employee information
        /// </summary>

        #region "Get Requested Employee Information"

        private void GetReqEmpInfo()
        {
            if (rdBtn.SelectedIndex == 1 && pplReqUser.Accounts.Count > 0)
            {
                obj.GetCurrentUserDetails(pplReqUser.CommaSeparatedAccounts, null, txtReqUserID,txtReqUserDivision, txtReqUserDept, txtReqUserPosCategory, txtReqUserMobNo);
            }
        }

        #endregion

        /// <summary>
        /// Radio button visibility for dynamic users
        /// </summary>
        /// <param name="tasktype"></param>
        /// <param name="optional"></param>
        /// <param name="OptionalUserName"></param>
       
        public void RadioButtionListvisibility(SPWeb oweb, string tasktype, bool optional, string OptionalUserName, int WFOrder)
        {
            try
            {
                if (Request.QueryString["Mode"] == "New")
                {
                    pnlForward.Visible = false;
                }
                else if (Request.QueryString["Mode"] == "Edit")
                {
                    if (tasktype == "Static")
                    {
                        pnlForward.Visible = false;
                    }
                    else if (tasktype == "Dynamic")
                    {
                        setRadioButtonVisibilityforDynamicType(WFOrder);
                    }
                    else if (tasktype == "UP Attribute")
                    {
                        pnlForward.Visible = false;
                    }
                    else if (tasktype == "EC (Externally Configured)")
                    {
                        pnlForward.Visible = false;
                    }

                    buttonVisibilty = demandVoucherclass.getForwardbuttonVisibility(SiteURL, WorkflowConfigList, MainLstName, WFOrder);
                    if (buttonVisibilty[3] == "True")
                    {
                        btnApprove.Visible = true;
                        btnReject.Visible = true;
                        btnSubmit.Visible = false;
                    }
                    else
                    {
                        btnApprove.Visible = false;
                        btnReject.Visible = false;
                        btnSubmit.Visible = true;
                    }
                    if (buttonVisibilty[4] == "False")
                    {
                        pnlCommentArea.Visible = false;
                    }

                }
            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms" + " :: " + "Parent" + " :: " + "RadioButtionListvisibility";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }

        }

        /// <summary>
        /// set radion buttons visibilty for the dynamic work flow users
        /// </summary>
        /// <param name="WFOrder"></param>
        
        public void setRadioButtonVisibilityforDynamicType(int WFOrder)
        {
            try
            {
                buttonVisibilty = demandVoucherclass.getForwardbuttonVisibility(SiteURL, WorkflowConfigList, MainLstName, WFOrder);
                if (buttonVisibilty[0] == "True")
                {
                    rtbSendBack.Visible = true;
                    rtbSendBack.Checked = true;
                }
                else
                {
                    rtbSendBack.Visible = false;
                }
                if (buttonVisibilty[1] == "True")
                {
                    rtbForwardOthers.Visible = true;
                }
                else
                {
                    rtbForwardOthers.Visible = false;
                }

                if (buttonVisibilty[2] == "True")
                {
                    rtbForward.Visible = true;
                }
                else
                {
                    rtbForward.Visible = false;
                }
                if (buttonVisibilty[0] == "False" && buttonVisibilty[1] == "False" && buttonVisibilty[2] == "False")
                {
                    pnlForward.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorMsgs = "Trig_AMJ_IT_Forms" + " :: " + "Parent" + " :: " + "setRadioButtonVisibilityforDynamicType";
                obj.GenerateExceptionLog(ErrorMsgs, ex.Message, "");
            }
        }

    }
}
